package microcredit.gui.editor.member;

import java.awt.BorderLayout;

import microcredit.gui.editor.AbstractEditorForm;
import microcredit.gui.handler.MemberToLoanHandler;
import microcredit.gui.selector.SelectorPanel;
import microcredit.model.Member;
import microcredit.model.MemberToLoan;

public class MemberLoanForm extends AbstractEditorForm<Member> {

	private SelectorPanel<MemberToLoan> selector;
	
	public MemberLoanForm() {
		setLayout(new BorderLayout());
		setTitle("Loans");
	}
	
	@Override
	public void apply(Member e) throws Throwable {
		if (selector != null) {
			remove(selector);
		}
		MemberToLoanHandler handler = new MemberToLoanHandler.ByMemberLoanHandler(e);
		selector = new SelectorPanel<MemberToLoan>(MemberToLoan.class, handler, 
				handler, 
				handler, 
				handler, null, null, null, null);
		add(selector);
	}

	@Override
	public Member receive(Member e) throws Throwable {
		// nothing to do
		return e;
	}

}
